//
//  MyHttpProcessor.m
//  iOS-CtrlV
//
//  Created by 龚 杰 on 12-12-26.
//  Copyright (c) 2012年 Wang Li. All rights reserved.
//

#import "MyHttpProcessor.h"
#import "ASIFormDataRequest.h"
#import "CJSONDeserializer.h"
#import "AlbumModel.h"
#import "UserInformationModel.h"
#import "BlogAndLikeListModel.h"
#import "FansAndAttentionListModel.h"

#define TT_RELEASE_SAFELY(__POINTER) { [__POINTER release]; __POINTER = nil; }

#define TARGAT_SINA @"sina"
#define TARGAT_QQ @"tencent"

@implementation MyHttpProcessor
@synthesize delegate;

static MyHttpProcessor *shareMyHttpProcessor = nil;

+ (MyHttpProcessor*)sharedManager

{
    if (shareMyHttpProcessor == nil) {
        shareMyHttpProcessor = [[MyHttpProcessor alloc] init];
    }
    return shareMyHttpProcessor;
}






- (void)dealloc
{
    self.delegate = nil;

    [super dealloc];
}

- (id)init
{
    if (self = [super init]) {
       
    }
    return self;
}
#pragma mark 个人信息
- (void)RequestPersonalInformationGet:(NSInteger)_userId ID:(NSInteger)_Id
{
    NSString* url = [NSString stringWithFormat:@"%@?app=userNew&act=detail&user_id=%d&id=%d",RequestMainURL,_userId,_Id];
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
//    [tGetRequest setTimeOutSeconds:20.f];
    NSLog(@"%@",url);
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(AnalyticalPersonalInformation:)];
    [tGetRequest startAsynchronous];
}
- (void)RequestPersonalInformationPost:(NSInteger)_userId ID:(NSInteger)_Id
{
    ASIFormDataRequest* tPostRequest =[ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?app=userNew&act=detail",RequestMainURL]]];
    [tPostRequest setDelegate:self];
    [tPostRequest setPostValue:[NSNumber numberWithUnsignedInt:_userId] forKey:@"user_id"];
    [tPostRequest setPostValue:[NSNumber numberWithUnsignedInt:_Id] forKey:@"id"];
    [tPostRequest setDidFinishSelector:@selector(AnalyticalPersonalInformation:)];
    [tPostRequest startAsynchronous];
}
- (void)AnalyticalPersonalInformation:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0)
    {
        NSError* tError= nil;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"errorCode"] intValue];
        if (tErrorCode == 0)
        {
            NSDictionary* dic = [tDictionary objectForKey:@"data"];
            UserInformationModel* usermodel = [[UserInformationModel alloc] init];
            NSObject* object;
            object = [dic objectForKey:@"id"];
            if (object == [NSNull null]) {
                usermodel.user_id = 0;
                object = nil;
            }else{
                usermodel.user_id = ((NSString*)object).integerValue;
                object = nil;
            }
            
            object = [dic objectForKey:@"nickname"];
            if (object == [NSNull null]) {
                usermodel.uesr_name = 0;
                object = nil;
            }else{
                usermodel.uesr_name = (NSString*)object;
                object = nil;
            }
            
            object = [dic objectForKey:@"avatar"];
            if (object == [NSNull null]) {
                usermodel.user_headimg_url = @"";
                object = nil;
            }else{
                usermodel.user_headimg_url = (NSString*)object;
                object = nil;
            }
            
            object = [dic objectForKey:@"follow_count"];
            if (object == [NSNull null]) {
                usermodel.uesr_follow_count = @"";
                object = nil;
            }else{
                usermodel.uesr_follow_count = (NSString*)object;
                object = nil;
            }
            NSLog(@"uesr_follow_count = %@",usermodel.uesr_follow_count);
            
            object = [dic objectForKey:@"fans_count"];
            if (object == [NSNull null]) {
                usermodel.user_fans_count = @"";
                object = nil;
            }else{
                usermodel.user_fans_count = (NSString*)object;
                object = nil;
            }
            NSLog(@"user_fans_count = %@",usermodel.user_fans_count);
            
            object = [dic objectForKey:@"blog_count"];
            if (object == [NSNull null]) {
                usermodel.user_blog_count = 0;
                object = nil;
            }else{
                usermodel.user_blog_count = ((NSString*)object).integerValue;
                object = nil;
            }

            object = [dic objectForKey:@"collect_count"];
            if (object == [NSNull null]) {
                usermodel.user_collect_count = 0;
                object = nil;
            }else{
                usermodel.user_collect_count = ((NSString*)object).integerValue;
                object = nil;
            }

            object = [dic objectForKey:@"like_count"];
            if (object == [NSNull null]) {
                usermodel.user_like_count = 0;
                object = nil;
            }else{
                usermodel.user_like_count = ((NSString*)object).integerValue;
                object = nil;
            }
            object = [dic objectForKey:@"share_to_sina"];
            if (object == [NSNull null]) {
                usermodel.user_share_to_sina= 0;
                object = nil;
            }else{
                usermodel.user_share_to_sina = ((NSString*)object).integerValue;
                object = nil;
            }
            object = [dic objectForKey:@"share_to_tencent"];
            if (object == [NSNull null]) {
                usermodel.user_share_to_tencent = 0;
                object = nil;
            }else{
                usermodel.user_share_to_sina = ((NSString*)object).integerValue;
                object = nil;
            }
            if (delegate !=nil) {
                [delegate OutPersonalInformationData:usermodel];
            }
            [usermodel release];
        }else{
            if (delegate != nil) {
                [delegate OurErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"errorMsg"] forKey:@"errorMsg"]];
            }
        }
    }else{
        if (delegate != nil) {
            [delegate OurErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"errorMsg"]];
        }
    }
}

#pragma mark 帖子列表
//- (void)RequestPostListGet:(NSInteger)_userId ID:(NSString*)_Id
//                     start:(NSInteger)_start limit:(NSInteger)_limit;
//{
//    NSString* url = [NSString stringWithFormat:@"%@?app=userNew&act=blogs&user_id=%d&id=%@&start=%d&limit=%d",
//                     RequestMainURL,_userId,_Id,_start,_limit];
//    
//	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
//    //    [tGetRequest setTimeOutSeconds:20.f];
//	[tGetRequest setDelegate:self];
//	[tGetRequest setDidFinishSelector:@selector(AnalyticalPostList:)];
//    [tGetRequest startAsynchronous];
//}
//
//- (void)RequestPostListPost:(NSInteger)_userId ID:(NSString*)_Id
//                      start:(NSInteger)_start limit:(NSInteger)_limit
//{
//    ASIFormDataRequest* tPostRequest =[ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?app=userNew&act=blogs",RequestMainURL]]];
//    [tPostRequest setDelegate:self];
//    [tPostRequest setPostValue:[NSNumber numberWithUnsignedInt:_userId] forKey:@"user_id"];
//    [tPostRequest setPostValue:_Id forKey:@"id"];
//    [tPostRequest setPostValue:[NSNumber numberWithUnsignedInt:_start] forKey:@"start"];
//    [tPostRequest setPostValue:[NSNumber numberWithUnsignedInt:_limit] forKey:@"limit"];
//    [tPostRequest setDidFailSelector:@selector(AnalyticalPostList:)];
//    [tPostRequest startAsynchronous];
//}
//- (void)AnalyticalPostList:(ASIHTTPRequest*)request
//{
//    //{
//    //list:{{
//    //    id:”20001”,
//    //image:”http://static.yourdomain.com/upload/kjujkjhuuejdfgt.png”, //290px*NA
//    //    image_width(int):290,
//    //    image_height(int):240,
//    //    description(string):”一个人总要走陌生的路，看陌生的风景，听陌生的歌，然…”,
//    //    forward(int):1
//    //    favorite(int):1
//    //    user_id(int):100001
//    //    user_nickname(string):”我是双子座”,
//    //user_avatar:”http://static.yourdomain.com/avatar/01/34/01345.png”, //75px*75px
//    //collect:”2013年事业运势早知道”,
//    //}}}
//    
//    NSString* tStrReq =[request responseString];
//    NSLog(@"%@",tStrReq);
//
//    if ([tStrReq length] > 0)
//    {
//        NSError* tError= nil;
//        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
//        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
//        int tErrorCode= [[tDictionary objectForKey:@"errorCode"] intValue];
//        NSMutableArray* bldate  = [[NSMutableArray alloc] init];
//        if (tErrorCode == 0)
//        {
//            NSArray*date = (NSArray*)[tDictionary objectForKey:@"list"];
//            for (NSDictionary* dic in  date) {
//                BlogAndLikeListModel* blmodel = [[BlogAndLikeListModel alloc] init];
//                blmodel.blog_id = (NSString*)[dic objectForKey:@"id"];
//                blmodel.blog_image_url = (NSString*)[dic objectForKey:@"image"];
//                blmodel.blog_image_width = ((NSString*)[dic objectForKey:@"image_width"]).integerValue;
//                blmodel.blog_image_height = ((NSString*)[dic objectForKey:@"image_height"]).integerValue;
//                blmodel.blog_favorite = ((NSString*)[dic objectForKey:@"favorite"]).integerValue;
//                blmodel.blog_forward = ((NSString*)[dic objectForKey:@"forward"]).integerValue;
//                blmodel.bolg_user_id = ((NSString*)[dic objectForKey:@"user_id"]).integerValue;
//                blmodel.blog_user_name = (NSString*)[dic objectForKey:@"user_nickname"];
//                blmodel.blog_user_headimageurl = (NSString*)[dic objectForKey:@"user_avatar"];
//                blmodel.bolg_collect = (NSString*)[dic objectForKey:@"collect"];
//                
//            }
//            if (delegate !=nil) {
//                [delegate OutPostListData:bldate];
//            }
//            [bldate removeAllObjects];
//            [bldate release];
//        }else{
//            
//            if (delegate != nil) {
//                [delegate OurErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"errorMsg"] forKey:@"errorMsg"]];
//            }
//        }
//    }else{
//        if (delegate != nil) {
//            [delegate OurErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"errorMsg"]];
//        }
//    }
//}

#pragma mark 专辑列表
- (void)RequestAlbumListGet:(NSInteger)_userId ID:(NSString*)_Id
                      start:(NSInteger)_start limit:(NSInteger)_limit
{
    NSString* url = [NSString stringWithFormat:@"%@?app=userNew&act=collects&user_id=%d&id=%@&page=%d&limit=%d",
                     RequestMainURL,_userId,_Id,_start,_limit];
     NSLog(@"%@==========",url);
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(AnalyticalAlbumList:)];
    [tGetRequest startAsynchronous];
}
- (void)RequestAlbumListPost:(NSInteger)_userId ID:(NSString*)_Id
                       start:(NSInteger)_start limit:(NSInteger)_limit
{
    ASIFormDataRequest* tPostRequest =[ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?app=userNew&act=collects",RequestMainURL]]];
    [tPostRequest setDelegate:self];
    [tPostRequest setPostValue:[NSNumber numberWithUnsignedInt:_userId] forKey:@"user_id"];
    [tPostRequest setPostValue:_Id forKey:@"id"];
    [tPostRequest setPostValue:[NSNumber numberWithUnsignedInt:_start] forKey:@"start"];
    [tPostRequest setPostValue:[NSNumber numberWithUnsignedInt:_limit] forKey:@"limit"];
    [tPostRequest setDidFinishSelector:@selector(AnalyticalAlbumList:)];
    [tPostRequest startAsynchronous];
}
- (void)AnalyticalAlbumList:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0)
    {
        NSError* tError= nil;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"errorCode"] intValue];
    
        if (tErrorCode == 0)
        {
            NSMutableArray* amodeldate  = [[NSMutableArray alloc] init];
            NSArray*date = (NSArray*)[tDictionary objectForKey:@"data"];
            for (NSDictionary* dic in  date) {
                NSObject* object;
                AlbumModel* amodel = [[AlbumModel alloc] init];
                object = [dic objectForKey:@"id"];
                if (object == [NSNull null]) {
                    amodel.albumid = @"";
                    object = nil;
                }else{
                    amodel.albumid = (NSString*)object;
                    object = nil;
                }
                
                object = [dic objectForKey:@"image"];
                if ( object == [NSNull null]) {
                    amodel.albumimgurl = @"";
                    object = nil;
                }else{
                    amodel.albumimgurl = (NSString*)object;
                    object = nil;
                }
                object = [dic objectForKey:@"title"];
                if ( object == [NSNull null]) {
                   amodel.albumtitle = @"";
                    object = nil;
                }else{
                    amodel.albumtitle = (NSString*)object;
                    object = nil;
                }
                object = [dic objectForKey:@"count"];
                if ( object == [NSNull null]) {
                    amodel.count = 0;
                    object = nil;
                }else{
                    amodel.count = ((NSString*)object).integerValue;
                    object = nil;
                }
                object = [dic objectForKey:@"user_id"];
                if ( object == [NSNull null]) {
                    amodel.userid = 0;
                    object = nil;
                }else{
                    amodel.userid = ((NSString*)object).integerValue;
                    object = nil;
                }
                object = [dic objectForKey:@"user_nickname"];
                if ( object == [NSNull null]) {
                    amodel.username = 0;
                    object = nil;
                }else{
                    amodel.username = (NSString*)object;
                    object = nil;
                }
                object = [dic objectForKey:@"image"];
                if ( object == [NSNull null]) {
                     amodel.userheadimgurls = nil;
                    object = nil;
                }else{
                    amodel.userheadimgurls = [NSArray arrayWithArray:(NSArray*)object];
                    object = nil;
                }
                for (NSString* url in  amodel.userheadimgurls) {
                    NSLog(@"images %@",url);
                }
                [amodeldate addObject:amodel];
                [amodel release];
            }
            if (delegate !=nil) {
                [delegate OutAlbumListData:amodeldate];
            }
            [amodeldate removeAllObjects];
            [amodeldate release];
        }else{
           
            if (delegate != nil) {
                [delegate OurErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"errorMsg"] forKey:@"errorMsg"]];
            }
        }
    }else{
        if (delegate != nil) {
            [delegate OurErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"errorMsg"]];
        }
    }
}

#pragma mark 喜好列表
//- (void)RequestGoodListGet:(NSInteger)_userId ID:(NSString*)_Id
//                     start:(NSInteger)_start limit:(NSInteger)_limit
//{
//    NSString* url = [NSString stringWithFormat:@"%@?app=userNew&act=likes&user_id=%d&id=%@&start=%d&limit=%d",
//                     RequestMainURL,_userId,_Id,_start,_limit];
//	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
//    //    [tGetRequest setTimeOutSeconds:20.f];
//	[tGetRequest setDelegate:self];
//	[tGetRequest setDidFinishSelector:@selector(AnalyticalGoodList:)];
//    [tGetRequest startAsynchronous];
//}
//- (void)RequestGoodListPost:(NSInteger)_userId ID:(NSString*)_Id
//                      start:(NSInteger)_start limit:(NSInteger)_limit
//{
//    ASIFormDataRequest* tPostRequest =[ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?app=userNew&act=likes",RequestMainURL]]];
//    [tPostRequest setDelegate:self];
//    [tPostRequest setPostValue:[NSNumber numberWithUnsignedInt:_userId] forKey:@"user_id"];
//    [tPostRequest setPostValue:_Id forKey:@"id"];
//    [tPostRequest setPostValue:[NSNumber numberWithUnsignedInt:_start] forKey:@"start"];
//    [tPostRequest setPostValue:[NSNumber numberWithUnsignedInt:_limit] forKey:@"limit"];
//    [tPostRequest setDidFinishSelector:@selector(AnalyticalGoodList:)];
//    [tPostRequest startAsynchronous];
//}
//- (void)AnalyticalGoodList:(ASIHTTPRequest*)request
//{
//    NSString* tStrReq =[request responseString];
//    NSLog(@"%@",tStrReq);
//    
//    if ([tStrReq length] > 0)
//    {
//        NSError* tError= nil;
//        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
//        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
//        int tErrorCode= [[tDictionary objectForKey:@"errorCode"] intValue];
//        
//        if (tErrorCode == 0)
//        {
//            NSMutableArray* ldate  = [[NSMutableArray alloc] init];
//            NSArray*date = (NSArray*)[tDictionary objectForKey:@"list"];
//            for (NSDictionary* dic in  date) {
//                BlogAndLikeListModel* lmodel = [[BlogAndLikeListModel alloc] init];
//                lmodel.blog_id = (NSString*)[dic objectForKey:@"id"];
//                lmodel.blog_image_url = (NSString*)[dic objectForKey:@"image"];
//                lmodel.blog_image_width = ((NSString*)[dic objectForKey:@"image_width"]).integerValue;
//                lmodel.blog_image_height = ((NSString*)[dic objectForKey:@"image_height"]).integerValue;
//                lmodel.blog_favorite = ((NSString*)[dic objectForKey:@"favorite"]).integerValue;
//                lmodel.blog_forward = ((NSString*)[dic objectForKey:@"forward"]).integerValue;
//                lmodel.bolg_user_id = ((NSString*)[dic objectForKey:@"user_id"]).integerValue;
//                lmodel.blog_user_name = (NSString*)[dic objectForKey:@"user_nickname"];
//                lmodel.blog_user_headimageurl = (NSString*)[dic objectForKey:@"user_avatar"];
//                lmodel.bolg_collect = (NSString*)[dic objectForKey:@"collect"];
//                [ldate addObject:lmodel];
//                
//            }
//            if (delegate !=nil) {
//                [delegate OutPostListData:ldate];
//            }
//            [ldate removeAllObjects];
//            [ldate release];
//        }else{
//            
//            if (delegate != nil) {
//                [delegate OurErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"errorMsg"] forKey:@"errorMsg"]];
//            }
//        }
//    }else{
//        if (delegate != nil) {
//            [delegate OurErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"errorMsg"]];
//        }
//    }
//}
//
#pragma mark 粉丝列表
- (void)RequestFansListGet:(NSInteger)_userId ID:(NSString*)_Id
                     start:(NSInteger)_start limit:(NSInteger)_limit
{
    NSString* url = [NSString stringWithFormat:@"%@?app=userNew&act=follows&type=2&user_id=%d&id=%@&page=%d&limit=%d",
                     RequestMainURL,_userId,_Id,_start,_limit];
     NSLog(@"urlFans = %@",url);
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(AnalyticalFansList:)];
    [tGetRequest startAsynchronous];
}
- (void)RequestFansListPost:(NSInteger)_userId ID:(NSString*)_Id
                      start:(NSInteger)_start limit:(NSInteger)_limit
{
    ASIFormDataRequest* tPostRequest =[ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?app=userNew&act=follows&type=2",RequestMainURL]]];
    [tPostRequest setDelegate:self];
    [tPostRequest setPostValue:[NSNumber numberWithUnsignedInt:_userId] forKey:@"user_id"];
    [tPostRequest setPostValue:_Id forKey:@"id"];
    [tPostRequest setPostValue:[NSNumber numberWithUnsignedInt:_start] forKey:@"start"];
    [tPostRequest setPostValue:[NSNumber numberWithUnsignedInt:_limit] forKey:@"limit"];
    [tPostRequest setDidFinishSelector:@selector(AnalyticalFansList:)];
    [tPostRequest startAsynchronous];
}
- (void)AnalyticalFansList:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"========%@",tStrReq);
    
    if ([tStrReq length] > 0)
    {
        NSError* tError= nil;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"errorCode"] intValue];

        if (tErrorCode == 0)
        {
            
            NSDictionary* dic1 = [tDictionary objectForKey:@"data"];
//            NSString* num = (NSString*)[dic1 objectForKey:@"count"];
            NSArray* date = (NSArray*)[dic1 objectForKey:@"list"];
            NSLog(@"data === %d",[date count]);
            NSMutableArray* fdate  = [[NSMutableArray alloc] init];
            for (NSDictionary* dic in  date) {
                FansAndAttentionListModel* fmodel = [[FansAndAttentionListModel alloc] init];
                fmodel.fans_id = (NSString*)[dic objectForKey:@"id"];
                fmodel.fans_user_name = (NSString*)[dic objectForKey:@"nickname"];
                fmodel.fans_user_headimageurl = (NSString*)[dic objectForKey:@"avatar"];
                fmodel.fans_user_followed = ((NSString*)[dic objectForKey:@"isfollowed"]).integerValue;
                [fdate addObject:fmodel];
                [fmodel release];
            }
            if (delegate !=nil) {
                [delegate OutFansLisData:fdate];
           }
            [fdate removeAllObjects];
            [fdate release];
        }else{
            
            if (delegate != nil) {
                [delegate OurErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"errorMsg"] forKey:@"errorMsg"]];
            }
        }
    }else{
        if (delegate != nil) {
            [delegate OurErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"errorMsg"]];
        }
    }
}

#pragma mark 关注列表
- (void)RequestAttentionListGet:(NSInteger)_userId ID:(NSString*)_Id
                          start:(NSInteger)_start limit:(NSInteger)_limit
{
    NSString* url = [NSString stringWithFormat:@"%@?app=userNew&act=follows&type=1&user_id=%d&id=%@&page=%d&limit=%d",
                     RequestMainURL,_userId,_Id,_start,_limit];
    NSLog(@"Attentionurl = %@",url);
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(AnalyticalAttentionList:)];
    [tGetRequest startAsynchronous];
}
- (void)RequestAttentionListPost:(NSInteger)_userId ID:(NSString*)_Id
                           start:(NSInteger)_start limit:(NSInteger)_limit
{
    ASIFormDataRequest* tPostRequest =[ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?app=userNew&act=follows&type=1",RequestMainURL]]];
    [tPostRequest setDelegate:self];
    [tPostRequest setPostValue:[NSNumber numberWithUnsignedInt:_userId] forKey:@"user_id"];
    [tPostRequest setPostValue:_Id forKey:@"id"];
    [tPostRequest setPostValue:[NSNumber numberWithUnsignedInt:_start] forKey:@"start"];
    [tPostRequest setPostValue:[NSNumber numberWithUnsignedInt:_limit] forKey:@"limit"];
    [tPostRequest setDidFinishSelector:@selector(AnalyticalAttentionList:)];
    [tPostRequest startAsynchronous];
}
- (void)AnalyticalAttentionList:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    
    if ([tStrReq length] > 0)
    {
        NSError* tError= nil;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"errorCode"] intValue];
        
        if (tErrorCode == 0)
        {
            NSDictionary* dic1 = [tDictionary objectForKey:@"data"];
//            NSString* num = (NSString*)[dic1 objectForKey:@"count"];
            NSArray* date = (NSArray*)[dic1 objectForKey:@"list"];
            NSMutableArray* ldate  = [[NSMutableArray alloc] init];
            for (NSDictionary* dic in  date) {
                FansAndAttentionListModel* lmodel = [[FansAndAttentionListModel alloc] init];
                NSObject* object;
                object = [dic objectForKey:@"id"];
                if (object == [NSNull null]) {
                    lmodel.fans_id = @"";
                    object = nil;
                }else{
                    lmodel.fans_id = (NSString*)object;
                    object = nil;
                }
                
                object = [dic objectForKey:@"nickname"];
                if (object == [NSNull null]) {
                    lmodel.fans_user_name = @"";
                    object = nil;
                }else{
                    lmodel.fans_user_name = (NSString*)object;
                    object = nil;
                }
                
                object = [dic objectForKey:@"avatar"];
                if (object == [NSNull null]) {
                    lmodel.fans_user_headimageurl = @"";
                    object = nil;
                }else{
                    lmodel.fans_user_headimageurl = (NSString*)object;
                    object = nil;
                }
                
                object = [dic objectForKey:@"isfollowed"];
                if (object == [NSNull null]) {
                    lmodel.fans_user_followed = 5;
                    object = nil;
                }else{
                    lmodel.fans_user_followed = ((NSString*)object).integerValue;
                    object = nil;
                }
                [ldate addObject:lmodel];
                [lmodel release];
            }
            if (delegate !=nil) {
                [delegate OutAttentionListData:ldate];
            }
            [ldate removeAllObjects];
            [ldate release];
        }else{
            
            if (delegate != nil) {
                [delegate OurErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"errorMsg"] forKey:@"errorMsg"]];
            }
        }
    }else{
        if (delegate != nil) {
            [delegate OurErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"errorMsg"]];
        }
    }
}
#pragma mark 查询专题
- (void)RequestAlbumSearchListGet:(NSString*)_userId
{
    NSString* url = [NSString stringWithFormat:@"%@?app=collect&act=search&user_id=%@",RequestMainURL,_userId];
    NSLog(@"url%@",url);
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(AnalyticalAlbumSearchList:)];
    [tGetRequest startAsynchronous];
}
- (void)RequestAlbumSearchListPost:(NSString*)_userId
{
    ASIFormDataRequest* tPostRequest =[ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?app=blog&act=search&",RequestMainURL]]];
    [tPostRequest setDelegate:self];
    [tPostRequest setPostValue:_userId forKey:@"user_id"];
    [tPostRequest setDidFinishSelector:@selector(AnalyticalAlbumSearchList:)];
    [tPostRequest startAsynchronous];
}
//             id(int):”10000”,
//                title(string):”小资美食花名册”,
//                blog_count(int):10,
- (void)AnalyticalAlbumSearchList:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    
    if ([tStrReq length] > 0)
    {
        NSError* tError= nil;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"errorCode"] intValue];
        if (tErrorCode == 0)
        {
            
            NSArray* getArray = (NSArray*)[tDictionary objectForKey:@"data"];
            NSMutableArray* iarray  = [[NSMutableArray alloc] init];
            for (NSDictionary* dic in  getArray) {
                NSObject* object;
                AlbumModel* aModel = [[AlbumModel alloc] init];
                object = [dic objectForKey:@"id"];
                if (object == [NSNull null]) {
                    aModel.albumid = @"";
                    object = nil;
                }else{
                    aModel.albumid = (NSString*)object;
                    object = nil;
                }

                object = [dic objectForKey:@"title"];
                if (object == [NSNull null]) {
                    aModel.albumtitle = @"";
                    object = nil;
                }else{
                    aModel.albumtitle = (NSString*)object;
                    object = nil;
                }
                
                object = [dic objectForKey:@"blog_count"];
                if (object == [NSNull null]) {
                    aModel.count = 0;
                    object = nil;
                }else{
                    aModel.count = ((NSString*)object).integerValue;
                    object = nil;
                }

                [iarray addObject:aModel];
                [aModel release];
            }
            if (delegate !=nil) {
                [delegate OutAlbumSearchListData:iarray];
            }
            [iarray removeAllObjects];
            [iarray release];
        }else{
            
            if (delegate != nil) {
                [delegate OurErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"errorMsg"] forKey:@"errorMsg"]];
            }
        }
    }else{
        if (delegate != nil) {
            [delegate OurErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"errorMsg"]];
        }
    }

}
#pragma mark 创建专题
- (void)RequestAlbumCreateGet:(NSString*)_userId title:(NSString*)_title
{
    NSString* url = [NSString stringWithFormat:@"%@?app=collect&act=create&user_id=%@&title=%@",RequestMainURL,_userId,_title];
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    NSLog(@"%@",url);
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(AnalyticalAlbumCreate:)];
    [tGetRequest startAsynchronous];
}
- (void)RequestAlbumCreatePost:(NSString*)_userId title:(NSString*)_title
{
    ASIFormDataRequest* tPostRequest =[ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?app=collect&act=create",RequestMainURL]]];
    [tPostRequest setDelegate:self];
    [tPostRequest setPostValue:_userId forKey:@"user_id"];
    [tPostRequest setPostValue:_title forKey:@"title"];
    [tPostRequest setDidFinishSelector:@selector(AnalyticalAlbumCreate:)];
    [tPostRequest startAsynchronous];
}
- (void)AnalyticalAlbumCreate:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0)
    {
        NSError* tError= nil;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"errorCode"] intValue];
        if (tErrorCode == 0)
        {
            AlbumModel* ialbumModel = [[AlbumModel alloc] init];
            NSObject* object = [tDictionary objectForKey:@"data"];
            
            if (object == [NSNull null]) {
                if (delegate != nil) {
                    [delegate OutAlbumCreate:nil];
                }
                object = nil;
            }else{
                NSDictionary* dic = (NSDictionary*)object;
                NSObject* object1;
                object1 = [dic objectForKey:@"collect_id"];
                if (object1 == [NSNull null]) {
                    ialbumModel.albumid = @"";
                    object1 = nil;
                }else{
                    ialbumModel.albumid = (NSString*)object1;
                    object1 = nil;
                }
                
                object1 = [dic objectForKey:@"collect_name"];
                if (object1 == [NSNull null]) {
                    ialbumModel.albumtitle = @"";
                    object1 = nil;
                }else{
                    ialbumModel.albumtitle = (NSString*)object1;
                    object1 = nil;
                }

                ialbumModel.count = 0;
                if (delegate != nil) {
                    [delegate OutAlbumCreate:ialbumModel];
                }
            }
          
            [ialbumModel release];
        }else{
            if (delegate != nil) {
                [delegate OurErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"errorMsg"] forKey:@"errorMsg"]];
            }
        }
    }else{
        if (delegate != nil) {
            [delegate OurErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"errorMsg"]];
        }
    }
}
#pragma mark 关注与取消关注
- (void)RequestFollowGet:(NSString*)user_id targe:(NSString*)target_user_id type:(NSInteger)_type
{
    NSString* url = [NSString stringWithFormat:@"%@?app=userNew&act=follow&type=%d&user_id=%@&target_user_id=%@",RequestMainURL,_type,user_id,target_user_id];
    NSLog(@"url = %@",url);
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(AnalyticalFollow:)];
    [tGetRequest startAsynchronous];
}
- (void)RequestFollowPost:(NSString*)user_id targe:(NSString*)target_user_id type:(NSInteger)_type
{
    ASIFormDataRequest* tPostRequest =[ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?app=userNew&act=follow&type=%d",RequestMainURL,_type]]];
    [tPostRequest setDelegate:self];
    [tPostRequest setPostValue:user_id forKey:@"user_id"];
    [tPostRequest setPostValue:target_user_id forKey:@"target_user_id"];
    [tPostRequest setDidFinishSelector:@selector(AnalyticalFollow:)];
    [tPostRequest startAsynchronous];
}
- (void)AnalyticalFollow:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0)
    {
        NSError* tError= nil;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"errorCode"] intValue];
        if (tErrorCode == 0)
        {
            NSDictionary* dic = [tDictionary objectForKey:@"data"];
            NSString* result = (NSString*)[dic objectForKey:@"result"];
            if (delegate != nil) {
                [delegate OutFollow:result];
            }
        }else{
            if (delegate != nil) {
                [delegate OurErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"errorMsg"] forKey:@"errorMsg"]];
            }
        }
    }else{
        if (delegate != nil) {
            [delegate OurErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"errorMsg"]];
        }
    }
}

//User_id	用户ID	String
//description	内容	String
//collect_id	专辑ID	String
//Share_to_sina	分享到新浪微博	int
//Share_to_tencent	分享到腾讯微博	int
//File_data	要上传的图片	file
#pragma mark 发布微博
- (void)RequestHairBlogPost:(NSString*)user_id description:(NSString*)_description collect_id:(NSString*)_collect_id
                       sina:(NSInteger)sina_to tencent:(NSInteger)tencent_to imagepath:(NSString*)_imagepath
{

    ASIFormDataRequest* tPostRequest =[ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?app=blog&act=publish",RequestMainURL]]];
    [tPostRequest setDelegate:self];
    [tPostRequest setPostValue:user_id forKey:@"user_id"];
    [tPostRequest setPostValue:_description forKey:@"description"];
    [tPostRequest setPostValue:_collect_id forKey:@"collect_id"];
    [tPostRequest setPostValue:[NSNumber numberWithInt:sina_to] forKey:@"Share_to_sina"];
    [tPostRequest setPostValue:[NSNumber numberWithInt:tencent_to] forKey:@"Share_to_tencent"];
    [tPostRequest setFile:_imagepath forKey:@"file_data"];
    [tPostRequest setDidFinishSelector:@selector(AnalyticalHairBlog:)];
    [tPostRequest startAsynchronous];
}
- (void)AnalyticalHairBlog:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0)
    {
        NSError* tError= nil;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"errorCode"] intValue];
        NSString* str = [tDictionary objectForKey:@"errorMsg"];
        if (tErrorCode == 0)
        {
            NSDictionary* dic = [tDictionary objectForKey:@"data"];
            NSString* result = (NSString*)[dic objectForKey:@"result"];
            if (delegate != nil) {
                [delegate OutHairBlogResults:result];
            }
        }else{
           if (delegate != nil) {
                [delegate OurErrer:[NSDictionary dictionaryWithObject:str forKey:@"errorMsg"]];
           }
        }
    }else{
        if (delegate != nil) {
            [delegate OurErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"errorMsg"]];
        }
    }
}

- (void)RequestTurnminingBlogGet:(NSString*)user_id description:(NSString*)_description collect_id:(NSString*)_collect_id
                             sina:(NSInteger)sina_to tencent:(NSInteger)tencent_to blogid:(NSInteger)blogid
{

    NSString* url = [NSString stringWithFormat:@"%@?app=blog&act=repost&user_id=%@&description=%@&collect_id=%@&Share_to_sina=%d&Share_to_tencent=%d&blog_id=%d",RequestMainURL,user_id,_description,_collect_id,sina_to,tencent_to,blogid];
    NSLog(@"url = %@",url);
    NSString* str1 = (NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)url, nil, nil, kCFStringEncodingUTF8);
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:str1]];
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(AnalyticalTurnminingBlog:)];
    [tGetRequest startAsynchronous];
    [str1 release];
}
- (void)RequestTurnminingBlogPost:(NSString*)user_id description:(NSString*)_description collect_id:(NSString*)_collect_id
                             sina:(NSInteger)sina_to tencent:(NSInteger)tencent_to blogid:(NSInteger)blogid
{
    ASIFormDataRequest* tPostRequest =[ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?app=blog&act=repost",RequestMainURL]]];
    [tPostRequest setDelegate:self];
    [tPostRequest setPostValue:user_id forKey:@"user_id"];
    [tPostRequest setPostValue:_description forKey:@"description"];
    [tPostRequest setPostValue:_collect_id forKey:@"collect_id"];
    [tPostRequest setPostValue:[NSNumber numberWithInt:sina_to] forKey:@"Share_to_sina"];
    [tPostRequest setPostValue:[NSNumber numberWithInt:tencent_to] forKey:@"Share_to_tencent"];
    [tPostRequest setPostValue:[NSNumber numberWithInt:blogid] forKey:@"blog_id"];
    [tPostRequest setDidFinishSelector:@selector(AnalyticalTurnminingBlog:)];
    [tPostRequest startAsynchronous];
}
- (void)AnalyticalTurnminingBlog:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0)
    {
        NSError* tError= nil;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"errorCode"] intValue];
        NSString* str = [tDictionary objectForKey:@"errorMsg"];
        if (tErrorCode == 0)
        {
            NSDictionary* dic = [tDictionary objectForKey:@"data"];
            NSString* result = (NSString*)[dic objectForKey:@"result"];
            if (delegate != nil) {
                [delegate OUtTurnminingBlogResults:result];
            }
        }else{
            if (delegate != nil) {
                [delegate OurErrer:[NSDictionary dictionaryWithObject:str forKey:@"errorMsg"]];
            }
        }
    }else{
        if (delegate != nil) {
            [delegate OurErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"errorMsg"]];
        }
    }
}

- (void)RequestUesrNameGet:(NSString*)_userId private_code:(NSString*)code name:(NSString*)name
{
    NSString* url = [NSString stringWithFormat:@"%@?app=userNew&act=update&id=%@&private_code=%@&nickname=%@",RequestMainURL,_userId,code,name];
    NSLog(@"url = %@",url);
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(AnalyticalUesrName:)];
    [tGetRequest startAsynchronous];
}
- (void)RequestUesrNamePost:(NSString*)_userId private_code:(NSString*)code name:(NSString*)name
{
    ASIFormDataRequest* tPostRequest =[ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?app=userNew&act=update",RequestMainURL]]];
    [tPostRequest setDelegate:self];
    [tPostRequest setPostValue:_userId forKey:@"id"];
    [tPostRequest setPostValue:code forKey:@"private_code"];
    [tPostRequest setPostValue:name forKey:@"nickname"];
    [tPostRequest setDidFinishSelector:@selector(AnalyticalUesrName:)];
    [tPostRequest startAsynchronous];
}
- (void)AnalyticalUesrName:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0)
    {
        NSError* tError= nil;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"errorCode"] intValue];
        if (tErrorCode == 0)
        {
            NSDictionary* dic = [tDictionary objectForKey:@"data"];
            NSString* result = (NSString*)[dic objectForKey:@"result"];
            if (delegate != nil) {
                [delegate OutUpdataName:result];
            }
        }else{
            if (delegate != nil) {
                [delegate OurErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"errorMsg"] forKey:@"errorMsg"]];
            }
        }
    }else{
        if (delegate != nil) {
            [delegate OurErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"errorMsg"]];
        }
    }
}

- (void)RequestUesrHaedPost:(NSString*)_userId private_code:(NSString*)code haed:(NSString*)haedpath
{
    ASIFormDataRequest* tPostRequest =[ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?app=userNew&act=updateAvatar",RequestMainURL]]];
    [tPostRequest setDelegate:self];
    [tPostRequest setPostValue:_userId forKey:@"id"];
    [tPostRequest setPostValue:code forKey:@"private_code"];
    [tPostRequest setFile:haedpath forKey:@"file_data"];
    [tPostRequest setDidFinishSelector:@selector(AnalyticalUesrHaed:)];
    [tPostRequest startAsynchronous];
}
- (void)AnalyticalUesrHaed:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0)
    {
        NSError* tError= nil;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"errorCode"] intValue];
        if (tErrorCode == 0)
        {
            NSDictionary* dic = [tDictionary objectForKey:@"data"];
            NSString* result = (NSString*)[dic objectForKey:@"result"];
            if (delegate != nil) {
                [delegate OutUpdataHaed:result];
            }
        }else{
            if (delegate != nil) {
                [delegate OurErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"errorMsg"] forKey:@"errorMsg"]];
            }
        }
    }else{
        if (delegate != nil) {
            [delegate OurErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"errorMsg"]];
        }
    }
}

- (void)RequestInsurgentblog:(NSString *)_userId target:(NSString *)_target
{
    NSString* url = [NSString stringWithFormat:@"%@?app=other&act=oauth&user_id=%@&target=%@",RequestMainURL,_userId,_target];
    NSLog(@"url = %@",url);
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(AnalyticalInsurgentblog:)];
    [tGetRequest startAsynchronous];
}
- (void)AnalyticalInsurgentblog:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0)
    {
        NSError* tError= nil;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"errorCode"] intValue];
        if (tErrorCode == 0)
        {
            NSDictionary* dic = [tDictionary objectForKey:@"data"];
            NSString* result = (NSString*)[dic objectForKey:@"result"];
            NSLog(@"%@",result);
            if (result == nil) {
                result =@"0";
              NSString* callback = [dic objectForKey:@"callback"];
              NSString* auth =[dic objectForKey:@"auth"];
                if (delegate!= nil) {
                    [delegate OutInsurgentblog:[NSDictionary dictionaryWithObjectsAndKeys:callback,@"callback",
                                                auth,@"auth",result,@"result",nil]];
                }
            }else{
                if (delegate!= nil) {
                    [delegate OutInsurgentblog:[NSDictionary dictionaryWithObjectsAndKeys:result,@"result",nil]];
                }
            }
        }else{
            if (delegate != nil) {
                [delegate OurErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"errorMsg"] forKey:@"errorMsg"]];
            }
        }
    }else{
        if (delegate != nil) {
            [delegate OurErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"errorMsg"]];
        }
    }
}

- (void)RequestCancelInsurgentblog:(NSString *)_userId target:(NSString *)_target
{
    NSString* url = [NSString stringWithFormat:@"%@?user_id=%@&target=%@",RequestMainURL,_userId,_target];
    NSLog(@"url = %@",url);
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(AnalyticalCancelInsurgentblog:)];
    [tGetRequest startAsynchronous];
}
- (void)AnalyticalCancelInsurgentblog:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0)
    {
        NSError* tError= nil;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"errorCode"] intValue];
        if (tErrorCode == 0)
        {
            NSDictionary* dic = [tDictionary objectForKey:@"data"];
            NSString* result = (NSString*)[dic objectForKey:@"result"];
            NSLog(@"%@",result);
            if (delegate!= nil) {
                [delegate OutCInsurgentblog:[NSDictionary dictionaryWithObjectsAndKeys:result,@"result",nil]];
            }
        }else{
            if (delegate != nil) {
                [delegate OurErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"errorMsg"] forKey:@"errorMsg"]];
            }
        }
    }else{
        if (delegate != nil) {
            [delegate OurErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"errorMsg"]];
        }
    }
}
#pragma mark-
#pragma mark ASIHTTPRequestDelegate
- (void)requestFailed:(ASIHTTPRequest *)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"err%@",tStrReq);
    if (delegate != nil) {
        [delegate OurErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"errorMsg"]];
    }
}


@end
